home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DRIVES.SWG / 0025_Disk Serial Numbers.pas < prev    next >
Pascal/Delphi Source File  |  1993-07-17  |  2KB  |  64 lines

  1. (*
  2. Date: 07-10-93 (02:15)
  3. From: LAWRENCE JOHNSTONE
  4. Subj: DISK'S SERIAL NUMBER.
  5. This will work under DOS 4.0 or later, according to Microsoft's MS-DOS
  6. Programmer's Reference (earlier versions of DOS didn't give disks
  7. serial numbers).
  8. *)
  9.  
  10. UNIT MediaID;
  11.  
  12. INTERFACE
  13.  
  14. TYPE
  15.   TMediaID = RECORD
  16.     InfoLvl:   WORD;
  17.     SerialNum: LONGINT;
  18.     VolLabel:  ARRAY [1..11] OF CHAR;
  19.     FileSys:   ARRAY [1..8] OF CHAR;
  20.   END;
  21.  
  22. FUNCTION GetMediaID( Drive: WORD; VAR MID:  TMediaID ): BOOLEAN;
  23.   (* Drive:  0=default, 1=A, 2=B, etc. *)
  24.  
  25. FUNCTION SetMediaID( Drive: WORD; CONST MID: TMediaID ): BOOLEAN;
  26.  
  27. IMPLEMENTATION
  28.  
  29. FUNCTION GetMediaID( Drive: WORD; VAR MID: TMediaID ): BOOLEAN;  ASSEMBLER;
  30.   ASM
  31.     push ds
  32.     mov  bx, [Drive]
  33.     mov  ch, $08       (* Device category (must be 08h) *)
  34.     mov  cl, $66       (* Minor code for Get Media ID function *)
  35.     lds  dx, [MID]     (* DS:DX -> TMediaID structure *)
  36.     mov  ax, $440D     (* Function 44 (IOCTL), subfunction 0D *)
  37.     int  $21
  38.     pop  ds
  39.     mov  ax, 0         (* Assume function failed *)
  40.     jc   @@Done
  41.     inc  ax            (* Didn't fail -- return TRUE *)
  42.   @@Done:
  43.   END;
  44.  
  45. FUNCTION SetMediaID( Drive: WORD; CONST MID: TMediaID ): BOOLEAN;  ASSEMBLER;
  46.   ASM
  47.     push ds
  48.     mov  bx, [Drive]
  49.     mov  ch, $08       (* Device category (must be 08h) *)
  50.     mov  cl, $46       (* Minor code for Set Media ID function *)
  51.     lds  dx, [MID]     (* DS:DX -> TMediaID structure *)
  52.     mov  ax, $440D     (* Function 44 (IOCTL), subfunction 0D *)
  53.     int  $21
  54.     pop  ds
  55.     mov  ax, 0         (* Assume function failed *)
  56.     jc   @@Done
  57.     inc  ax            (* Didn't fail -- return TRUE *)
  58.   @@Done:
  59.   END;
  60.  
  61.  
  62. END.
  63.  
  64.